﻿using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
using UnityEngine.Events;

public class MonoManager : BaseManager<MonoManager>
{

    private MonoController monoController;

    public MonoManager()
    {
        //保证了MonoController对象的唯一性
        GameObject obj = new GameObject("MonoController");
        monoController = obj.AddComponent<MonoController>();
    }
    /// <summary>
    /// 添加Update事件监听，这是通过封装MonoController中的方法实现的
    /// </summary>
    /// <param name="func"></param>
    public void AddUpdateListener(UnityAction func)
    {
        monoController.AddUpdateListener(func);
    }
    public void RemoveUpdateListener(UnityAction func)
    {
        monoController.RemoveUpdateListener(func);
    }

    //下面封装一些mono中的协程方法 
    public Coroutine StartCoroutine(string methodName)
    {
        return monoController.StartCoroutine(methodName);
    }

    public Coroutine StartCoroutine(string methodName, [DefaultValue("null")] object value)
    {
        return monoController.StartCoroutine(methodName, value);
    }

    public Coroutine StartCoroutine(IEnumerator routine)
    {
        return monoController.StartCoroutine(routine);
    }

    public void StopCoroutine(IEnumerator routine)
    {
         monoController.StopCoroutine(routine);
    }
    public void StopCoroutine(Coroutine routine)
    {
        monoController.StopCoroutine(routine);
    }
    public void StopCoroutine(string methodName)
    {
        monoController.StopCoroutine(methodName);
    }



}
